Q3CString_GetString
You can use theQ3CString_GetString
function to get the character data of a C string object.
TQ3Status Q3CString_GetString ( TQ3StringObject stringObj, char **string);
stringObj
- A C string object.
string
- On entry, the value
NULL
. On exit, a pointer to a copy of the character data associated with the specified C string object.DESCRIPTION
TheQ3CString_GetString
function returns, through thestring
parameter, a pointer to a copy of the character data associated with the C string object specified by thestringObj
parameter. The value of thestring
parameter must beNULL
when you callQ3CString_GetString
, because it allocates memory and overwrites thestring
parameter. For instance, the following sequence of calls will cause a memory leak:
myStatus = Q3CString_GetString(myStringObj, &myString); myStatus = Q3CString_GetString(myStringObj, &myString);After the second call toQ3CString_GetString
, the memory allocated by the first call toQ3CString_GetString
is leaked; you cannot deallocate that memory because you've lost its address. You must make certain to callQ3CString_EmptyData
to release the memory allocated byQ3CString_GetString
when you are finished using the string data, and always before callingQ3CString_GetString
with the same string pointer. Here is an example:
myStatus = Q3CString_GetString(myStringObj, &myString); myStatus = Q3CString_EmptyData(&myString); myStatus = Q3CString_GetString(myStringObj, &myString);If the value of thestring
parameter is notNULL
,Q3CString_GetString
generates a warning.You should use
Q3CString_GetString
only with string objects of typekQ3StringTypeCString
.ERRORS AND WARNINGS
kQ3WarningPossibleMemoryLeak